package com.ctaa.ctaa.controller;

import com.ctaa.ctaa.dto.Result;
import com.ctaa.ctaa.pojo.UserInfoPojo;
import com.ctaa.ctaa.service.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("user")
public class UserController {

    @Resource
    private UserService userService;

    //登陆
    @GetMapping("login")
    public Result<UserInfoPojo> login(@RequestParam("email") String email, @RequestParam("password") String password) {
        return userService.login(email, password);
    }


    //注册
    @GetMapping("regist")
    public Result<Boolean> regist(@RequestParam("userName") String userName,
                                  @RequestParam("password") String password,
                                  @RequestParam("email") String email) {
        return userService.regist(userName, password, email);
    }

    //找回密码
    @GetMapping("forgotPassword")
    public Result<Boolean> forgotPassword(@RequestParam("email") String email) {
        return userService.forgotPassword(email);
    }


    //修改密码
    @GetMapping("modifyPass")
    public Result<Boolean> modifyPass(@RequestParam("email") String email, @RequestParam("password") String password) {
        return userService.modifyPass(email, password);
    }
}
